'''
for
for 变量名 in 序列:
    循环体
while
'''
names = {"tom","李四","lucy","lily","张三"}
for name in names: # name代表names中的每个元素
    print(name,end=",")
print()
# range() 生成一组整数序列 1 10
'''
range(start,end,step)
    start:开始值,默认是0
    end:结束值， 范围：[start,end)
    step:跨步，默认值为1
'''

for a in range(1,11,1):
    print(a,end="  ")
print()
for a in range(1,11,2):
    print(a,end="  ")
print()

# 简写
for a in range(11): # 从0开始，跨步为1
    print(a,end=" ")
print()
for a in range(3,11): # 跨步为1
    print(a,end=" ")
print()

b = range(3,12,3)
b = list(b)
print(b)

c = list(range(3,12,3))
print(c)

print(list(range(12,-1,-2)))

# 案例：求和：1-100的和
# 1+2+3+4...+100
# 定义一个变量：和sum
sum = 0
for n in range(1,101):
    # sum = sum + n
    sum += n
print(sum)

# 1000-3000以内的，能被7和5整除的数
for num in range(1000,3001):
    if num%7 == 0 and num%5 == 0:
        print(num,end=",")
print()


# 显示结果为类似：1，2，3，4
flog = True # 标记，用来判断是不是第一个数
for num in range(1000,3001):
    if num%7 == 0 and num%5 == 0:
        # 第一个数，打印前面不加,
        if flog:
            print(num,end="")
            flog = False
        # 之后所有的数打印 ,数
        else:
            print(",",num,end="",sep="")

